package com.fizzkai.p2p.website.controller;

import com.fizzkai.p2p.core.service.IAccountService;
import com.fizzkai.p2p.core.service.IUserInfoService;
import com.fizzkai.p2p.core.util.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class BorrowController {

    @Autowired
    private IAccountService accountService;
    @Autowired
    private IUserInfoService userInfoService;

    @RequestMapping("/borrow")
    public String borrow(Model model){
        if (UserContext.getCurrentLoginInfo() == null) {
            return "/borrowIndex.html";
        }
        model.addAttribute("account", accountService.getCurrent());
        model.addAttribute("userInfo", userInfoService.getCurrent());
        return "borrow";
    }
}
